package com.zha.boss.exceptions.handle;

import com.zha.boss.enums.resp.RespCode;
import com.zha.boss.exceptions.BossException;
import com.zha.boss.mvc.models.resp.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: zha
 * @CreateTime: 2024年09月06日 8:11
 */
@RestControllerAdvice
public class GlobalExceptionHandle {
    private Logger log = LoggerFactory.getLogger(getClass());
    /*处理BossException*/
    @ExceptionHandler({ BossException.class})
    public AjaxResult doBossException(BossException e){
        RespCode respCode = e.getRespCode();
        log.error("异常类型BossException错误原因:{}---{}",respCode.getCode(),respCode.getMsg());
        return AjaxResult.warn(respCode);
    }
}
